/**
* @description: 836. 矩形重叠
* @author hewei
* @date 2022/7/29 15:33
* @version 1.0
*/

public class IsRectangleOverlap {

    public boolean isRectangleOverlap1(int[] rec1, int[] rec2) {
        if (rec1[0] == rec1[2] || rec2[0] == rec2[2] || rec2[1] == rec2[3] || rec1[1] == rec1[3]) return false;
        return !(rec1[2] <= rec2[0] || rec1[1] >= rec2[3] || rec1[3] <= rec2[1] || rec1[0] >= rec2[2]);
    }

    public boolean isRectangleOverlap(int[] rec1, int[] rec2) {
        return Math.max(rec1[0], rec2[0]) < Math.min(rec1[2], rec2[2]) && Math.max(rec1[1], rec2[1]) < Math.min(rec1[3], rec2[3]);
    }
}
